*********************************************************************************
*** Figure 5
*********************************************************************************

* Project: 	International threats and European defense
* Authors: 	Matthias Mader
* Date:		March 2023	

* Data: VW Project, Pane-European survey (W1)

*********************************************************************************

*** Setup

	clear
	set more off            						// Disable partitioned output
	set dp period									// Use comma instead of dot for decimals
	set linesize 80         						// Line size limit to make output more readable
	macro drop _all         						// clear all macros
	set scheme plotplainblind, permanent				// set graph scheme, e.g., cleanplots, plottig, plotplainblind, burd3, s1mono
	graph set window fontface "Times New Roman"		// set font in graphs | "Arial" | "Times New Roman"


*** Figure 5
	
	use DATA_clean, clear

	*Top left
	reg csdp_wouldlike c.threat_ind2##c.eurid i.QCOUNTRY female age ib2.education iso comp mili
	estimates store m2
	margins, at(threat_ind2=(0 (.025) 1) eurid=(0 1))
	marginsplot,  ///
		name(g1, replace) ///
		recast(scatter) ///
		plot1opts(mcolor(none)) plot2opts(mcolor(none)) ///
		text(0.85 -0.01 "Strong attachment to Europe", color(gs9) place(right) size(large)) ///
		text(0.40 -0.01  "No attachment to Europe", color(gs0) place(right) size(large)) ///
		ciopts(recast(rbar) barwidth(0.01)) ///
		xtitle("Threat perception", size(large)) xscale(range(0 1)) xlabel(0 (0.2) 1, nogrid labsize(large)) ///	
		ytitle("Support for security/defence integration", size(large)) yscale(range(0 1)) ylabel(0 (0.2) 1, nogrid labsize(large)) ///	
		title("") ///
		legend(off)

	*Top right
	reg csdp_wouldlike c.threat_ind2##c.feel_EU i.QCOUNTRY female age ib2.education iso comp mili
	margins, at(threat_ind2=(0 (.025) 1) feel_EU=(0 1))
	marginsplot,  ///
		name(g2, replace) ///
		recast(scatter) ///
		plot1opts(mcolor(none)) plot2opts(mcolor(none)) ///
		text(0.85 -0.01 "EU supporters", color(gs9) place(right) size(large)) ///
		text(0.40 -0.01  "EU opponents", color(gs0) place(right) size(large)) ///
		ciopts(recast(rbar) barwidth(0.01)) ///
		xtitle("Threat perception", size(large)) xscale(range(0 1)) xlabel(0 (0.2) 1, nogrid labsize(large)) ///	
		ytitle("Support for security/defence integration", size(large)) yscale(range(0 1)) ylabel(0 (0.2) 1, nogrid labsize(large)) ///	
		title("") ///
		legend(off)

	*Bottom left
	reg csdp_tasks c.threat_ind2##i.idconfig2 i.QCOUNTRY female age ib2.education iso comp mili
	estimates store m2
	margins, at(threat_ind2=(0 (.025) 1) idconfig2=(1 2))
	marginsplot,  ///
		name(g3, replace) ///
		recast(scatter) ///
		plot1opts(mcolor(none)) plot2opts(mcolor(none)) ///
		text(0.73 -0.01 "Inclusive identity", color(gs9) place(right) size(large)) ///
		text(0.40 -0.01  "Exclusive national identity", color(gs0) place(right) size(large)) ///
		ciopts(recast(rbar) barwidth(0.01)) ///
		xtitle("Threat perception", size(large)) xscale(range(0 1)) xlabel(0 (0.2) 1, nogrid labsize(large)) ///	
		ytitle("Support for CSDP tasks", size(large)) yscale(range(0 1)) ylabel(0 (0.2) 1, nogrid labsize(large)) ///	
		title("  ") ///
		legend(off)

	*Bottom right
	ologit csdp_decisionrule c.threat_ind2##i.idconfig2 i.QCOUNTRY female age education iso comp mili
	estimates store m2
	margins, at(threat_ind2=(0 (.025) 1) idconfig2=(1 2)) predict(outcome(3))
	marginsplot,  ///
		name(g4, replace) ///
		recast(scatter) ///
		plot1opts(mcolor(none)) plot2opts(mcolor(none)) ///
		text(0.23 -0.01 "Inclusive identity", color(gs9) place(right) size(large)) ///
		text(0.02 -0.01  "Exclusive national identity", color(gs0) place(right) size(large)) ///
		ciopts(recast(rbar) barwidth(0.01)) ///
		xtitle("Threat perception", size(large)) xscale(range(0 1)) xlabel(0 (0.2) 1, nogrid labsize(large)) ///	
		ytitle("Support for majority rule", size(large)) yscale(range(0 1)) ylabel(0 (0.2) 1, nogrid labsize(large)) ///	
		title("") ///
		legend(off)
